#include <math.h>
#include <iostream>
using std::cout;
using std::endl;

//友元之友元类的形式
//将Line设置为Point的友元类
class Line;
class Point{
public:
    Point(int x, int y)
    :_x(x)
    ,_y(y)
    {

    }
    //直接将当前Line声明为Point的友元
    //那么当前Line里面的所有的成员函数均可以访问Point的私有数据成员
    friend class Line;
private:
    int _x;
    int _y;
};

class Line{
public:
    float distance(const Point & lhs,const Point & rhs){
        //让Point提供公有的get函数i
        //sqrt(a *a + b * b)
        int x = lhs._x - rhs._x;
        int y = lhs._y - rhs._y;
        return sqrt(pow(x , 2) + pow(y, 2));
    }
};


void test(){
    Line line;
    float result = line.distance(Point(1, 1), Point(4, 5));
    cout << result << endl;
}

int main()
{
    test();
    return 0;
}

